#!/usr/bin/env ruby
# -*- encoding : utf-8 -*-

require 'bundler'
Bundler.setup
require File.expand_path('../../lib/rabbit_jobs', __FILE__)

class MyCurrentJob
  include RJ::Job
  def perform(count = 0)
    puts count
    # RJ.publish_to(:default, MyCurrentJob, count - 1) if count > 0
  end
end

RJ.configure { |c|
  c.queue "mandarin", durable: true, auto_delete: false, manual_ack: true, arguments: {'x-ha-policy' => 'all'}
  c.server "amqp://localhost/rj"
}

worker = RJ::Worker.new
worker.work